<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        // 转换整数parseInt
        console.log(parseInt("10")) //10
        console.log(parseInt("10sss")) //10
        console.log(parseInt("g10")) //Nan
        console.log(parseInt("1sda0"))//1
        console.log(parseInt("10.98"))//10
        console.log(parseInt("10.98dagg"))//10

        //转小数parseFloat
        console.log(parseFloat("10")) //10
        console.log(parseFloat("10sss")) //10
        console.log(parseFloat("g10")) //Nan
        console.log(parseFloat("1sda0"))//1
        console.log(parseFloat("10.98"))//10.98
        console.log(parseFloat("10.98dagg"))//10.98

        //转数字 Number
        console.log(Number("10")) //10
        console.log(Number("10sss")) //NaN
        console.log(Number("g10")) //Nan
        console.log(Number("1sda0"))//Nan
        console.log(Number("10.98"))//10.98
        console.log(Number("10.98dagg"))//Nan
        
        //转换整数用parseInt  转换小数用parseFloat   转换数字用Number 他比上面的两种转换方式更加严格

        //转换字符串 toString
        var num = 10;
        console.log(num.toString()) //转换字符串

        //空变量转换字符串 String()
        var num1;
        var num2 = null;
        console.log(String(num1)) //undefined
        console.log(String(num2)) //null

        //转换Boolen
        console.log(Boolean(1)) //true
        console.log(Boolean(0)) //false
        console.log(Boolean("sss")) //true
        console.log(Boolean("")) //false
        console.log(Boolean(null)) //false
        console.log(Boolean(undefined)) //false
    </script>
</head>
<body>
    
</body>
</html>